﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Xajhzwb.Components.Util;

namespace Xajhzwb.Components.Gather
{
    public class GatherTaskSplit
    {
        private readonly Object m_threadLock = new Object();
        private Thread m_Thread;
        private bool m_ThreadRunning = false;

        private Const.GatherThreadState m_ThreadState;

        public DataTable GatherData { get; set; }

        internal bool IsThreadAlive
        {
            get { return m_Thread != null && m_Thread.IsAlive; }
        }

        public bool IsCompleted
        {

        }


        public void Start()
        {
            if(m_ThreadState != Const.GatherThreadState.Started && !IsThreadAlive && !IsCompleted)
            {
                lock(m_threadLock)
                {
                    m_ThreadRunning = true;
                    m_Thread = new Thread(this.ThreadWorkInit);

                    m_Thread.Name = m_TaskID.ToString() + "-" + m_TaskSplitData.BeginIndex.ToString();

                    m_Thread.Start();
                    m_ThreadState = cGlobalParas.GatherThreadState.Started;
                }
            }
        }






    }
}
